home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / Level4.txt < prev    next >
Encoding:
Text File  |  1998-05-11  |  2.5 KB  |  94 lines

  1. [ Level-4 registration routine ]
  2. --------------------------------
  3.  
  4. I will not post the step-by-step solution this time. You'll have to
  5. figure out this one yourself.  I believe you should have enough practice.
  6. But here are a few pointers...
  7.  
  8. First, unlike the previous registration routines, this one involves a
  9. funtion call.  That means, when you encounter the "call ..." you will
  10. need to use the [F8] command in Softice to trace INTO the function.
  11. Other than that, there isn't much difference.  But noticed that
  12. a string comparing function is not used here.  I wrote my own
  13. instructions to compare the two strings (generated key & the key entered),
  14. but it should be relatively simple.
  15.  
  16. Try not to look at the solution code before you even attempt to hack it.
  17.  
  18. Good Luck!
  19.  
  20.  
  21.  
  22.  
  23. Actual C++ codes, Solution
  24. ---------------------------
  25.  
  26. void CCrackMeDlg::Validate()
  27. {
  28.   int i = 0, slen = 0;
  29.   DWORD value1 = 0, value2 = 0;
  30.   CString usrn = "", key = "";
  31.   char keystr[30] = "\0";
  32.  
  33.   GetDlgItemText(IDC_USRN, usrn); // username entered
  34.   GetDlgItemText(IDC_KEY, key); // key/password entered
  35.   slen = usrn.GetLength();
  36.   if ((slen < 5) || (slen > 256))
  37.   {
  38.     MessageBox("User Name must be between 5 to 256 characters.",
  39.      "CrackMe", MB_OK | MB_ICONINFORMATION);
  40.     return;
  41.   }
  42.   if (key.IsEmpty())
  43.     return; // quit if empty key
  44.   Get2Values(usrn, slen, value1, value2); // function call!!!
  45.   wsprintf(keystr, "%lu-%X", value1, value2);
  46.      // print values to string "keystr" as unsigned long & hex digits 
  47.   slen = lstrlen(keystr);
  48.   key.MakeReverse();
  49.   do
  50.   {
  51.     if (i < key.GetLength())
  52.     {
  53.       if (key[i] != keystr[i])
  54.         break;
  55.     }
  56.     i++;
  57.   } while (keystr[i] > 0);
  58.   if ((i - slen) == 0)
  59.     // correct key
  60.   else
  61.     // incorrect key
  62. }
  63.  
  64. void CCrackMeDlg::Get2Values(CString &usrn, int slen, DWORD &value1, DWORD &value2)
  65. {
  66.   register int i;
  67.   for (i = 0; i < slen; i++)
  68.   {
  69.     if ((i % 2) != 0)
  70.       value1 = GetValue(usrn, slen, value2+i);
  71.     else
  72.       value2 = GetValue(usrn, slen, value1+i);
  73.   }
  74. }
  75.  
  76. DWORD CCrackMeDlg::GetValue(CString &usrn, int slen, DWORD value)
  77. {
  78.   register int i, j;
  79.   int clen;
  80.   DWORD retval = 1;
  81.  
  82.   clen = lstrlen((LPCTSTR) code1);
  83.   for (i = 0; i < slen; i++)
  84.   {
  85.     retval *= usrn[i];
  86.     for (j = 0; j < (clen/2); j++)
  87.       retval += (code1[j] - (usrn[i] % (j+1)) + code1[clen-j-1]);
  88.     retval *= (i+1);
  89.     retval <<= 8;
  90.     retval ^= value;
  91.   }
  92.   return (retval);
  93. }
  94.